<template>
  <svg :class="svgClass" aria-hidden="true">
    <use :xlink:href="iconName"></use>
  </svg>
</template>

<script setup lang="ts">
const props = defineProps({
  iconName: {type: String, required: true}, //iconfont中的名字
  className: {type: String, default: ''}, // // 添加自定义类名
})

const svgClass = computed(() => {
  if (props.className) {
    return `svg-icon ${props.className}`
  } else {
    return `svg-icon`
  }
})

const iconName = computed(() => {
  return `#${props.iconName}`
})
</script>

<style lang="scss" scoped>
.svg-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  overflow: hidden;
  vertical-align: -0.15em;
  fill: currentcolor;
}
</style>

